package com.guava;

import com.google.common.base.CharMatcher;

/**
 * 描述:
 *
 * @author luzhongfu
 * Created by lucky on 2021-10-08 5:52 PM
 */
public class CharMatcherTest {


    public static void main(String[] args) {
        String string =" aaaaa2211QV ";
        String noControl = CharMatcher.javaIsoControl().removeFrom(string); //移除control字符
        String theDigits = CharMatcher.inRange('0','9').retainFrom(string); //只保留数字字符
        String spaced = CharMatcher.whitespace().trimAndCollapseFrom(string, ' ');
//去除两端的空格，并把中间的连续空格替换成单个空格
        String noDigits = CharMatcher.inRange('0','9').replaceFrom(string, "*"); //用*号替换所有数字
        String lowerAndDigit = CharMatcher.inRange('a','z').retainFrom(string);
// 只保留数字和小写字母
        System.out.println();

    }
}
